const reg = /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/
const isPrivate = (r) => {
  let [first, second] = r.split('.')
  first = parseInt(first)
  second = parseInt(second)
  if (
    first === 10 ||
    (first === 172 && second >= 16 && second <= 31) ||
    (first === 192 && second === 168)
  ) {
    return true
  }
  return false
}

const isSubMask = (str) => {
  const a = str.split('.')
  let s = ''
  a.forEach((item) => {
    s += Number(item).toString(2).padStart(8, '0')
  })
  if (s.indexOf('01') > -1) return false
  if (s.indexOf('1') < 0 || s.indexOf('0') < 0) return false
  return true
}

const data = []
// while ((l = readline())) {
// const [ip, mask] = l.split('~')
// data.push({
//   ip,
//   mask,
// })
// }
l = '10.70.44.68~255.254.255.0'
const [ip, mask] = l.split('~')
data.push({
  ip,
  mask,
})

const isTest = () => {
  const counter = { a: 0, b: 0, c: 0, d: 0, e: 0, err: 0, private: 0 }
  data.forEach((item) => {
    const { ip, mask } = item
    const f = +ip.split('.')[0]
    // console.log(ip, f)
    if (f === 0 || f === 127) {
      // continue
    } else if (!isSubMask(mask)) {
      counter.err++
    } else if (!reg.test(ip)) {
      counter.err++
    } else {
      if (isPrivate(ip)) {
        counter.private++
      }
      if (f > 0 && f < 127) {
        counter.a++
      } else if (f > 127 && f < 192) {
        counter.b++
      } else if (f > 191 && f < 224) {
        counter.c++
      } else if (f > 223 && f < 240) {
        counter.d++
      } else if (f > 239 && f < 256) {
        counter.e++
      }
    }
  })
  console.log(
    counter.a +
      ' ' +
      counter.b +
      ' ' +
      counter.c +
      ' ' +
      counter.d +
      ' ' +
      counter.e +
      ' ' +
      counter.err +
      ' ' +
      counter.private
  )
}
isTest()
